import {ReqAllCategory,ReqPublicNumDaily} from '../api/index'
import {RECEIVECATEGORY,RECEIVEDATAColletion} from './action-type'
export default {
 /*  //存储用户信息的同步action，登录时使用
  store_user ({commit},userInfo) {
    commit(STOREUSER,userInfo)
  },
  //获取用户信息的异步action，实现自动登录
  async GetUser ({commit}) {
    let result = await AutoLogin()
    if(result.code === 0){
      commit(STOREUSER,result.data)
    }
  }, */
  // 发送请求获取分类信息，异步action
  async GetCategory ({commit}) {
    let result = await ReqAllCategory()
    if(result.code === 0){
      commit(RECEIVECATEGORY,result.data)
    }
  },
  async PublicNumDaily ({commit},data) {
    let {cur_day,cb} = data
    let result = await ReqPublicNumDaily(cur_day)
    //console.log('发送请求获取数据')
    if(result.code === 0){
      //console.log('分发action 这是callback',data)
      commit(RECEIVEDATAColletion,result.data)
      cb && cb()
    }
  }
  
}